<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style type="text/css"></style>
</head>
<body>
        <h1>获取属性</h1>
    <hr>

    <img src="./imgs/Meinv001.jpg" alt="这是一张图片" title="MM001" width="600" height="300" id="myimg" teshudeci="abc" data-img="666666">


    <script>
        //  获取属性值
        console.log(myimg.src); // HTML DOM
        console.log(myimg.getAttribute('src')); // XML DOM
        console.log(myimg.getAttributeNode('src').nodeValue); // XML DOM

        // console.log(myimg.teshudeci); // NO
        // console.log(myimg.data-img); // NO
        console.log(myimg.getAttribute('teshudeci')); // XML DOM
        console.log(myimg.getAttribute('data-img')); // XML DOM

        console.log(myimg.getAttributeNode('teshudeci').nodeValue); // XML DOM
        console.log(myimg.getAttributeNode('data-img').nodeValue); // XML DOM

    </script>



</body>
</html>



